<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表现</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        ul {
            overflow-y: scroll;
            height: 90vh;
        }
        
        li {
            display: flex;
            justify-content: space-between;
            list-style: none;
            height: 13vw;
            line-height: 13vw;
        }
        
        li div h3 {
            margin-left: 1vw;
        }
    </style>
    <link rel="stylesheet" href="http://localhost:3000/layui/layuiTablePlug/layui/src/css/layui.css">
    <script src="http://localhost:3000/layui/layuiTablePlug/layui/src/layui.js"></script>
    <script src="http://localhost:3000/js/ajax.js"></script>
</head>

<body>
    <div style="position: fixed;top:0;width: 100%;">
        <div style="background-color: #49CED0;color:#ffffff;padding-left: 15vw;font-weight:normal;height: 13vw;line-height: 13vw;display: flex;align-items: center;">
            <img src="http://localhost:3000/img/mobile/白色返回.png" alt="" style="position: absolute;left: 2vw;top: 2vw;width: 8vw;height:8vw;color: white;" class="cancel">
            <span style="background-color: #ffffff;height: 7vw;width: 1px;margin-right: 5vw;"></span>
            <h2>表现</h2>
        </div>
        <ul style="background-color: #ffffff;margin-top: 2vw;">

        </ul>
        <script>
            var url = window.location //获取前一个页面传递的参数
            var str = url.search.substring(1)
            str = decodeURI(str) //decodeURI()这个方法是用来解决获取到的search参数中文百分号乱码问题
            var uname = str
            var cancel = document.getElementsByClassName('cancel')[0]
            cancel.onclick = () => {
                window.location.href = `http://localhost:3000/stu?${uname}`
            }
            var ul = document.getElementsByTagName('ul')[0]
            window.onload = () => {
                // ul.innerHTML = '平时'
                ajax({
                    type: 'GET',
                    url: 'http://localhost:3000',
                    path: '/selectScore',
                    port: '',
                    data: {},
                    success: (data) => {
                        data = JSON.parse(data)
                        ul.innerHTML = ''
                        for (var i = 0; i < data.length; i++) {
                            ul.innerHTML += `
                     <li>
                     <div style="display:flex;justify-content:space-around;align-items:center;padding-left:2vw;"><h3>${parseInt(i)+1}</h3>
                     <h3 style="font-weight:bold;">${data[i].name}</h3></div>
                     <div style="display:flex;justify-content:space-around;align-items:center;">   <h2>${data[i].star}</h2>
                     <img src="http://localhost:3000/img/icon/星星.png" alt="" style="width:6vw;height:6vw;padding-right:2vw;"></div>
                     </li>  <div style="width:100vw;height:1px;background:#dbdbdb;"></div>`
                        }
                    },
                    error: (err) => {
                        console.log(err)
                    }
                })
            }
        </script>
</body>

</html>